<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="个人申请与审核信息" name="first"></el-tab-pane>
      <el-tab-pane label="集体申请与审核信息" name="second"></el-tab-pane>
    </el-tabs>
    <div class="filter-container">
      <el-form inline>
        <el-form-item label="姓名">
          <el-input v-model="listQuery.applicantName" placeholder="姓名" />
        </el-form-item>
        <el-form-item label="身份证号">
          <el-input v-model="listQuery.applicantNum" placeholder="身份证号" />
        </el-form-item>
        <el-form-item label="复垦类型">
          <el-select
            placeholder="复垦类型"
            v-model="listQuery.reclaimTypeId"
            clearable
          >
            <el-option
              v-for="(item, index) in fukenList"
              :key="index"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="状态">
          <el-select placeholder="状态" v-model="listQuery.landAuditStatus">
            <el-option
              v-for="(item, index) in shenChaList"
              :key="index"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button @click="changePage(1)" type="primary">查询</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="filter-container">
      <router-link :to="{ name: '个人申请添加' }">
        <el-button class="filter-item" type="primary" icon="el-icon-plus"
          >添加</el-button
        >
      </router-link>
    </div>

    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="加载中"
      highlight-current-row
    >
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="applyNum"
        label="申请编号"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="applicantName"
        label="姓名"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="applicantNum"
        label="身份证号码"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="address"
        label="通讯地址"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="mobilePhone"
        label="手机号码"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="reclaimWhere.name"
        label="复垦类型"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="auditStatus"
        label="审查状态"
      ></el-table-column>
      <el-table-column label="操作" width="230">
        <template slot-scope="scope">
          <router-link
            :to="{ name: '个人申请详情', query: { id: scope.row.landId } }"
          >
            <el-button size="small" style="margin-right: 5px;" type="primary"
              >申请详情</el-button
            >
          </router-link>
          <router-link
            :to="{ name: '个人审核详情', query: { id: scope.row.landId } }"
          >
            <el-button size="small" type="primary">审核详情</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination
        @current-change="changePage"
        :page-size="listQuery.size"
        layout="prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import {
  getList,
  findDetailByDictionaryType,
  getLandAuditStatus
} from "@/api/project/fksqtc/personApplyCheck";

export default {
  filters: {},
  data() {
    return {
      list: null,
      total: null,
      listLoading: false,
      listQuery: {
        page: 1,
        size: 10,
        applicantName: null,
        applicantNum: null,
        reclaimTypeId: null,
        landAuditStatus: null
      },
      shenChaList: [], //审查类型列表
      fukenList: [], //复垦类型列表
      activeName: "first"
    };
  },
  created() {
    this.getShenChaList();
    this.getFukenType();
  },
  methods: {
    handleClick(tab, event) {
      this.$router.push({
        path: "/ncjsydfk/sqyssxx/groupApplyCheck/list"
      });
    },
    //获取复垦类型列表
    getFukenType() {
      var data = {
        dictionaryType: "RECLAIM_TYPE"
      };
      findDetailByDictionaryType(data).then(res => {
        console.log(res, "复垦类型列表");
        this.fukenList = res.data;
      });
    },
    //获取审查状态列表
    getShenChaList() {
      var data = {};
      getLandAuditStatus(data).then(res => {
        console.log(res, "审查状态");
        this.shenChaList = res.data;
        this.listQuery.landAuditStatus = res.data[0].code;
        this.fetchData();
      });
    },
    fetchData() {
      this.listLoading = true;
      getList(this.listQuery)
        .then(res => {
          this.listLoading = false;
          this.list = res.data.rows;
          this.total = res.data.total;
        })
        .catch(err => {
          this.listLoading = false;
        });
    },
    changePage(page) {
      this.listQuery.page = page;
      this.fetchData();
    }
  }
};
</script>
